package util;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public class JsonUtil {
	 @SuppressWarnings("unchecked")
	public static Object toJsonObject(String jsonString, @SuppressWarnings("rawtypes") Class clazz){
	        ObjectMapper mapper = new ObjectMapper();
	        Object obj = null;
	        try {
	            obj = mapper.readValue(jsonString, clazz);
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return obj;
	    }

	    public static String toJsonString(Object object){
	        ObjectMapper mapper = new ObjectMapper();
	        String result = null;
	        try {
	            result = mapper.writeValueAsString(object);
	        } catch (JsonProcessingException e) {
	            e.printStackTrace();
	        }
	        return result;
	    }
}
